package com.skeletonee.dao.example;


import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;

import com.skeletonee.model.example.Foo;
import com.xyzsoftware.commons.kernel.dao.jpa.JPADao;

@Repository
public class FooDaoJPA extends JPADao<Foo> implements FooDao{
	
	public FooDaoJPA(){
	}
	
	@PersistenceContext
    public void setEntityManager(EntityManager entityManager) {
        this. entityManager = entityManager;
    }

	public Foo get(String name) {
		String jpql = "SELECT m FROM " + 
			entityClass.getName() + " AS m WHERE m.name = :id ";
	
		return (Foo)entityManager.createQuery( jpql )
			.setParameter("name", name ).getSingleResult();
	}

}
